package com.chensheng.handler;

import com.chensheng.exception.SellException;
import com.chensheng.dto.ResultDTO;
import com.chensheng.exception.SellerAuthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author:ChenSheng
 * @Description:
 * @Date: Created in 上午 7:40 2018/5/14 0014
 */
@ControllerAdvice
public class WholeExceptionHandler {

    @ExceptionHandler(value = SellException.class)
    @ResponseBody
    public ResultDTO handleSellException(SellException e){
        return ResultDTO.error(e.getMessage());
    }

    @ExceptionHandler(value = SellerAuthorizedException.class)
    public ModelAndView handleSellException(SellerAuthorizedException e){
        return new ModelAndView("redirect:/seller/user/login");
    }
}
